<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
    <th:block th:include="include :: header('设备修改')" />
    <th:block th:include="include :: datetimepicker-css" />
    <style type="text/css">
        table label.error{position: inherit;}select + label.error{z-index:1;right:40px;}
    </style>
</head>
<body class="gray-bg">
<div class="main-content">
    <form class="form-horizontal m" id="form-device-edit" th:object="${myDevice}">
        <input name="id" th:field="*{id}" type="hidden">
        <input name="deviceDetails.id" th:field="*{deviceDetails.id}" type="hidden">
        <div class="row">
            <div class="col-sm-6">
                <div class="form-group">
                    <label class="col-sm-4 control-label is-required">设备名称：</label>
                    <div class="col-sm-8">
                        <input name="name" th:field="*{name}" class="form-control" type="text">
                    </div>
                </div>
            </div>
            <div class="col-sm-6">
                <div class="form-group">
                    <label class="col-sm-4 control-label is-required">设备串口：</label>
                    <div class="col-sm-8">
                        <input name="serialPort" th:field="*{serialPort}" class="form-control" type="text">
                    </div>
                </div>
            </div>
        </div>
        <div class="row">
            <div class="col-sm-6">
                <div class="form-group">
                    <label class="col-sm-4 control-label">比特率：</label>
                    <div class="col-sm-8">
                        <input name="bitRate" th:field="*{bitRate}" class="form-control" type="text">
                    </div>
                </div>
            </div>
            <div class="col-sm-6">
                <div class="form-group">
                    <label class="col-sm-4 control-label is-required">设备运行状态：</label>
                    <div class="col-sm-8">
                        <div class="input-group date">
                            <!--<input name="state" th:field="*{state}" class="form-control" type="text">-->
                            <select class='form-control' name='state' th:field="*{state}" disabled>
                                <option value="1" {{if state===1}}selected{{/if}}>已停止</option>
                                <option value="2" {{if state===2}}selected{{/if}}>正在运行</option>
                            </select>
                        </div>
                    </div>
                </div>
            </div>
        </div>
        <div class="row">
            <div class="col-sm-6">
                <div class="form-group">
                    <label class="col-sm-4 control-label">设备运行时间：</label>
                    <div class="col-sm-8"><!--th:value="${#dates.format(myDevice.runTime, 'yyyy-MM-dd')}"-->
                        <input name="runTime" th:value="*{runTime}" class="form-control"  type="text" disabled>
<!--                        <span class="input-group-addon"><i class="fa fa-calendar"></i></span>-->
                    </div>
                </div>
            </div>
            <div class="col-sm-6">
                <div class="form-group">
                    <label class="col-sm-4 control-label is-required">备注：</label>
                    <div class="col-sm-8">
                        <div class="input-group date">
                            <textarea name="remark" class="form-control">[[*{remark}]]</textarea>
                        </div>
                    </div>
                </div>
            </div>
        </div>

        <div class="row">
            <div class="col-sm-6">
                <div class="form-group">
                    <label class="col-sm-4 control-label">CGMS机器 当前真空度：</label>
                    <div class="col-sm-8"><!--th:value="${#dates.format(myDevice.runTime, 'yyyy-MM-dd')}"-->
                        <input name="deviceDetails.p1Now" th:value="*{deviceDetails.p1Now}" class="form-control"  type="text" disabled>

                    </div>
                </div>
            </div>
            <div class="col-sm-6">
                <div class="form-group">
                    <label class="col-sm-4 control-label ">样品舱 当前真空度：</label>
                    <div class="col-sm-8">
                        <div class="input-group date">
                            <input name="deviceDetails.p2Now" th:value="*{deviceDetails.p2Now}" class="form-control"  type="text" disabled>
                        </div>
                    </div>
                </div>
            </div>
        </div>

        <div class="row">
            <div class="col-sm-6">
                <div class="form-group">
                    <label class="col-sm-4 control-label is-required">样品舱真空度 设定值：</label>
                    <div class="col-sm-8">
                        <input name="deviceDetails.p2Seting" th:value="*{deviceDetails.p2Seting}" class="form-control"  type="text" >
                    </div>
                </div>
            </div>
<!--            <div class="col-sm-6">-->
<!--                <div class="form-group">-->
<!--                    <label class="col-sm-4 control-label is-required">舱体升温速率设定值：</label>-->
<!--                    <div class="col-sm-8">-->
<!--                        <div class="input-group date">-->
<!--                            <input name="deviceDetails.pt1Seting" th:value="*{deviceDetails.pt1Seting}" class="form-control"  type="text" >-->
<!--                        </div>-->
<!--                    </div>-->
<!--                </div>-->
<!--            </div>-->
        </div>

        <div class="row">
            <div class="col-sm-6">
                <div class="form-group">
                    <label class="col-sm-4 control-label ">样品仓 当前温度：</label>
                    <div class="col-sm-8">
                        <input name="deviceDetails.cangtiH11Now" th:value="*{deviceDetails.cangtiH11Now}" class="form-control"  type="text" disabled>
                    </div>
                </div>
            </div>
        </div>
        <div class="row">
            <div class="col-sm-6">
                <div class="form-group">
                    <label class="col-sm-4 control-label is-required">样品仓 温度设定值：</label>
                    <div class="col-sm-8">
                        <input name="deviceDetails.cangtiT0Seting" th:value="*{deviceDetails.cangtiT0Seting}" class="form-control"  type="text" >
                    </div>
                </div>
            </div>
<!--            <div class="col-sm-6">-->
<!--                <div class="form-group">-->
<!--                    <label class="col-sm-4 control-label">样品仓2 温度设定值：</label>-->
<!--                    <div class="col-sm-8">-->
<!--                        <div class="input-group date">-->
<!--                            <input name="deviceDetails.cangtiT1Seting" th:value="*{deviceDetails.cangtiT1Seting}" class="form-control"  type="text" disabled>-->
<!--                        </div>-->
<!--                    </div>-->
<!--                </div>-->
<!--            </div>-->
            <!--<div class="col-sm-6">
                <div class="form-group">
                    <label class="col-sm-4 control-label is-required">捕集阱前当前温度：</label>
                    <div class="col-sm-8">
                        <div class="input-group date">
                            <input name="deviceDetails.bujijingQH1Now" th:value="*{deviceDetails.bujijingQH1Now}" class="form-control"  type="text" disabled>
                        </div>
                    </div>
                </div>
            </div>-->
        </div>

        <div class="row">
            <div class="col-sm-6">
                <div class="form-group">
                    <label class="col-sm-4 control-label is-required">捕集阱 低温温度值：</label>
                    <div class="col-sm-8">
                        <input name="deviceDetails.bujijingT2Now" th:value="*{deviceDetails.bujijingT2Now}" class="form-control"  type="text" disabled>
                    </div>
                </div>
            </div>
            <div class="col-sm-6">
                <div class="form-group">
                    <label class="col-sm-4 control-label is-required">捕集阱 低温设定值：</label>
                    <div class="col-sm-8">
                        <div class="input-group date">
                            <input name="deviceDetails.bujijingT2Seting" th:value="*{deviceDetails.bujijingT2Seting}" class="form-control"  type="text">
                        </div>
                    </div>
                </div>
            </div>
        </div>

        <div class="row">
            <div class="col-sm-6">
                <div class="form-group">
                    <label class="col-sm-4 control-label">捕集阱 高温温度值：</label>
                    <div class="col-sm-8">
                        <input name="deviceDetails.bujijingT3Now" th:value="*{deviceDetails.bujijingT3Now}" class="form-control"  type="text" disabled>
                    </div>
                </div>
            </div>
            <div class="col-sm-6">
                <div class="form-group">
                    <label class="col-sm-4 control-label is-required">捕集阱 高温设定值：</label>
                    <div class="col-sm-8">
                        <div class="input-group date">
                            <input name="deviceDetails.bujijingT3Seting" th:value="*{deviceDetails.bujijingT3Seting}" class="form-control"  type="text" >
                        </div>
                    </div>
                </div>
            </div>
        </div>

        <div class="row">
            <div class="col-sm-6">
                <div class="form-group">
                    <label class="col-sm-4 control-label">捕集阱前 当前温度：</label>
                    <div class="col-sm-8">
                        <input name="deviceDetails.bujijingT41Now" th:value="*{deviceDetails.bujijingT41Now}" class="form-control"  type="text" disabled>
                    </div>
                </div>
            </div>
            <div class="col-sm-6">
                <div class="form-group">
                    <label class="col-sm-4 control-label is-required">捕集阱前 温控设置：</label>
                    <div class="col-sm-8">
                        <div class="input-group date">
                            <input name="deviceDetails.bujijingT41Seting" th:value="*{deviceDetails.bujijingT41Seting}" class="form-control"  type="text" >
                        </div>
                    </div>
                </div>
            </div>
        </div>

        <div class="row">
            <div class="col-sm-6">
                <div class="form-group">
                    <label class="col-sm-4 control-label">捕集阱后 当前温度：</label>
                    <div class="col-sm-8">
                        <input name="deviceDetails.bujijingT42Now" th:value="*{deviceDetails.bujijingT42Now}" class="form-control"  type="text" disabled>
                    </div>
                </div>
            </div>
            <div class="col-sm-6">
                <div class="form-group">
                    <label class="col-sm-4 control-label is-required">捕集阱后 温控设置：</label>
                    <div class="col-sm-8">
                        <div class="input-group date">
                            <input name="deviceDetails.bujijingT42Seting" th:value="*{deviceDetails.bujijingT42Seting}" class="form-control"  type="text" >
                        </div>
                    </div>
                </div>
            </div>
        </div>

 <!--       <div class="row">
                   <div class="col-sm-6">-->
<!--                <div class="form-group">-->
<!--                    <label class="col-sm-4 control-label">自动四通选择阀当前温度：</label>-->
<!--                    <div class="col-sm-8">-->
<!--                        <input name="deviceDetails.t5Now" th:value="*{deviceDetails.t5Now}" class="form-control"  type="text" disabled>-->
<!--                    </div>-->
<!--                </div>-->
<!--            </div>-->
<!--            <div class="col-sm-6">-->
<!--                <div class="form-group">-->
<!--                    <label class="col-sm-4 control-label is-required">自动四通选择阀设定值：</label>-->
<!--                    <div class="col-sm-8">-->
<!--                        <div class="input-group date">-->
<!--                            <input name="deviceDetails.t5Seting" th:value="*{deviceDetails.t5Seting}" class="form-control"  type="text" >-->
<!--                        </div>-->
<!--                    </div>-->
<!--                </div>-->
<!--            </div>
        </div>-->

        <div class="row">
            <div class="col-sm-6">
                <div class="form-group">
                    <label class="col-sm-4 control-label is-required">舱体真空稳定时间 设定值：</label>
                    <div class="col-sm-8">
                        <input name="deviceDetails.cangtiC1Seting" th:value="*{deviceDetails.cangtiC1Seting}" class="form-control"  type="text" >
                    </div>
                </div>
            </div>
            <div class="col-sm-6">
                <div class="form-group">
                    <label class="col-sm-4 control-label is-required">舱体恒温烘烤时间 设定值：</label>
                    <div class="col-sm-8">
                        <div class="input-group date">
                            <input name="deviceDetails.cangtiC2Seting" th:value="*{deviceDetails.cangtiC2Seting}" class="form-control"  type="text" >
                        </div>
                    </div>
                </div>
            </div>
        </div>

        <div class="row">
            <div class="col-sm-6">
                <div class="form-group">
                    <label class="col-sm-4 control-label is-required">捕集阱富集时间 设定值：</label>
                    <div class="col-sm-8">
                        <input name="deviceDetails.bujijingC3Seting" th:value="*{deviceDetails.bujijingC3Seting}" class="form-control"  type="text" >
                    </div>
                </div>
            </div>
            <div class="col-sm-6">
                <div class="form-group">
                    <label class="col-sm-4 control-label is-required">捕集阱高温维持时间 设定值：</label>
                    <div class="col-sm-8">
                        <div class="input-group date">
                            <input name="deviceDetails.bujijingC4Seting" th:value="*{deviceDetails.bujijingC4Seting}" class="form-control"  type="text" >
                        </div>
                    </div>
                </div>
            </div>
        </div>

        <div class="row">
            <div class="col-sm-6">
                <div class="form-group">
                    <label class="col-sm-4 control-label">当前模式：</label>
                    <div class="col-sm-8">
                        <input name="deviceDetails.nowmod" th:value="*{deviceDetails.nowmod}" class="form-control"  type="text" disabled>
                    </div>
                </div>
            </div>
        </div>

    </form>
</div>


<th:block th:include="include :: footer" />
<th:block th:include="include :: datetimepicker-js" />
<script th:src="@{/js/jquery.tmpl.js}"></script>
<script th:inline="javascript">
    var prefix = ctx + "system/device";
    var detail_prefix = ctx + "system/details";
    $("#form-device-edit").validate({
        focusCleanup: true
    });
    $(document).ready(function() {
        setInterval(function() {
            $.ajax({
                url: detail_prefix + "/portDate",
                type: "post",
                dataType: "json",
                success: function(data) {
                    // 处理成功的响应
                    console.log(data);
                    if (data.code == 0) {
                        $("#form-device-edit").find("input[name='deviceDetails.cangtiH11Now']").val(data.data.cangtiH11Now);
                        $("#form-device-edit").find("input[name='deviceDetails.cangtiH12Now']").val(data.data.cangtiH12Now);
                        $("#form-device-edit").find("input[name='deviceDetails.p1Now']").val(data.data.p1Now);
                        $("#form-device-edit").find("input[name='deviceDetails.p2Now']").val(data.data.p2Now);
                    } else {
                        layer.msg(data.msg);
                    }
                },
                error: function(error) {
                    // 处理错误的响应
                    console.log(error);
                }
            });
        }, 1000); // 每1000毫秒（1秒）发送一次请求
    });


  /*  $.validator.addMethod("goodsName", function(value, element) {
        return !this.optional(element);
    }, "商品名称必填。");

    $.validator.addMethod("goodsWeight", function(value, element) {
        return !this.optional(element) && (value <= 100 && value >= 0);
    }, "商品重量长度区间0-100。");*/

    /* 主子表-提交 */
    function submitHandler(index, layero){
        if ($.validate.form()) {

            if ($.validate.form()) {
                $.operate.save(prefix + "/edit", $('#form-device-edit').serialize());
            }
        }
    }





    $("#bootstrap-table").on("post-body.bs.table", function (e, args) {
        $("input[name$='runTime']").datetimepicker({
            format: "yyyy-mm-dd",
            minView: "month",
            autoclose: true,
            pickerPosition:'top-right'
        });
    });

    $("input[name='runTime']").datetimepicker({
        format: "yyyy-mm-dd",
        minView: "month",
        autoclose: true
    });
</script>
</body>
</html>

<!-- 商品类型 -->
<script id="stateTpl" type="text/x-jquery-tmpl">
    <div>
    <select class='form-control' name='detailsList[${index}].state'>
        <option value="1" {{if type===1}}selected{{/if}}>已停止</option>
        <option value="2" {{if type===2}}selected{{/if}}>正在运行</option>
    </select>
    </div>
</script>